package com.itl.lesson02.dao.impl;

import com.alibaba.fastjson.JSON;
import com.itl.lesson02.dao.HuGuangDao;
import com.itl.lesson02.dto.HuGuang;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 胡广
 * @date 2020-11-04
 * @since JDK1.8
 */
@Component
public class HuGuangDaoImpl implements HuGuangDao {

    @Resource
    private RedisTemplate<String,HuGuang> redisTemplate;

    @Override
    public void  add(HuGuang huGuang) {
        redisTemplate.opsForValue().set(huGuang.getCode(), huGuang);
    }

    @Override
    public HuGuang  get(String code) {
        return redisTemplate.opsForValue().get(code);
    }

    @Override
    public void  remove(String code) {
//        redisTemplate.opsForValue().set(code,null);
        redisTemplate.delete(code);
    }




}
